import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * Created by Jesse Phillips
 * Created on 1-Dec-05
 */
/**
 * Detailed discription of the class.
 * 
 * <p><b>
 * Extra Credit:
 * </b><pre>
 * Attempted extra credit not yet stated.
 * </pre><b>
 * 
 * History:
 * </b><pre>
 * 1-Dec-05: Project started. Project finished.
 * </pre>
 * 
 * @author Jesse Phillips
 * @see "No barrowed code."
 */
public class FileReverseDriver {
	BufferedReader input;
	PrintWriter output;
	
	public static void main(String args[]) {
		FileReverseDriver reverser;
		try {
			reverser = new FileReverseDriver();
			reverser.run();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public FileReverseDriver() throws FileNotFoundException {
		Scanner userInput = new Scanner(System.in);
		try {
			setupIO(userInput);
		} catch(FileNotFoundException fnfe) {
			System.out.println("No such File!!");
			try {
				setupIO(userInput);
			} catch (FileNotFoundException e) {
				System.out.println("User is stupid, leaving.");
				throw e;
			} catch (IOException e) {
				e.printStackTrace();
				System.exit(-1);
			}
		}catch(IOException io) {
			System.out.println(io);
			System.exit(-1);
		}
	}
	
	private void setupIO(Scanner userInput) throws FileNotFoundException, IOException {
		input = new BufferedReader(new FileReader(getInputFile(userInput)));
		output = new PrintWriter(new FileWriter(getOutputFile(userInput)));
	}

	private String getOutputFile(Scanner userInput) {
		return "testinput.txt";
	}

	private String getInputFile(Scanner userInput) {
		return "testoutput.txt";
	}
	
	private String reverse(BufferedReader reader) {
/*ans bl*/
		int intChar;
		try {
			intChar = reader.read();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
		if(intChar < 0)
			return "";
		else
			return reverse(reader) + (intChar==13?"":(char)intChar);
/*ans ab*/
	}

	private void run() {
		output.print(reverse(input));
		output.close();
	}
}
